
CC = gcc
RM = rm -f

WORKSPACE := $(shell cd .. && pwd)
CFLAGS := -Wall -O $(CFLAGS) -std=gnu11 -I$(WORKSPACE)/worker
LINK_LIBS = -lpthread

TARGET_TEST_WORKER = test_worker
TEST_WORKER_OBJS = test_worker.o worker.o

TARGET_TEST_TASK1 = test_task1
TEST_TASK1_OBJS = daemon.o test_task1.o worker.o

TARGET_TEST_TASK2 = test_task2
TEST_TASK2_OBJS = daemon.o test_task2.o worker.o


ALL: $(TARGET_TEST_WORKER) $(TARGET_TEST_TASK1) $(TARGET_TEST_TASK2)
	@echo "Compile all"
	ls -l $(TARGET_TEST_WORKER)
	ls -l $(TARGET_TEST_TASK1)
	ls -l $(TARGET_TEST_TASK2)

$(TARGET_TEST_WORKER): $(TEST_WORKER_OBJS)
	$(CC) $^ -o $@ $(LINK_LIBS)

$(TARGET_TEST_TASK1): $(TEST_TASK1_OBJS)
	$(CC) $^ -o $@ $(LINK_LIBS)

$(TARGET_TEST_TASK2): $(TEST_TASK2_OBJS)
	$(CC) $^ -o $@ $(LINK_LIBS)

%.o : %.c
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	$(RM) *.o $(TARGET_TEST_WORKER) $(TARGET_TEST_TASK1) $(TARGET_TEST_TASK2)

